package clientdcsinstance.pds.uchiha.test;

import org.omg.CORBA.Object;

import clientdcsinstance.client.impl.ClientRemoteImpl;
import clientdcsinstance.pds.uchiha.corba.manager.CorbaManager;
import clientdcsinstance.server.domaines.RemoteDomaineManager;
import clientdcsinstance.server.domaines.RemoteDomaineManagerHelper;
import clientdcsinstance.server.interfaces.Suscriber;
import clientdcsinstance.server.operations.OperationType;
import clientdcsinstance.server.operations.Replicated;
import clientdcsinstance.server.operations.impl.OperationFactory;



public class Main {
	public static void main(String[] args) {
		
		Object rDomaine1 = CorbaManager.getInstance().getReference("RemoteDomaine");
		RemoteDomaineManager rdomaine = RemoteDomaineManagerHelper.narrow(rDomaine1);
		Suscriber suscriber[] = rdomaine.getTopicsSuscribers(args[0], null);
		
		if(suscriber[0] == null){
			System.out.println("erruer 1");
			return;
		}
		
		ClientRemoteImpl client = new ClientRemoteImpl();
		client.createPublisher(suscriber[0]);
		client.buildDataWriter(null);
		OperationFactory factory = new OperationFactory();
		client.writeOperation(args[0], factory.buildOperation("topic", OperationType.create, Replicated.isReplicated, args[1]));
		CorbaManager.getInstance().shutdown();
	}
}
